﻿using DevComponents.DotNetBar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ThucThe;
using DieuKhien;
namespace GiaoDien
{
    public partial class QL : Form
    {
        public QL()
        {
            InitializeComponent();
        }

        private void btnItem_Tour_Click(object sender, EventArgs e)
        {
            TabControlPanel tabCtrlPanel_Tour;
            tabCtrlPanel_Tour = new TabControlPanel();
            tabCtrlQL.Controls.Add(tabCtrlPanel_Tour);
            tabCtrlPanel_Tour.SuspendLayout();

            TabItem tabItem_Tour = new TabItem();
            tabCtrlQL.Tabs.Add(tabItem_Tour);
            // 
            // tabItem_Tour
            // 
            tabItem_Tour.AttachedControl = tabCtrlPanel_Tour;
            tabItem_Tour.Name = "tabItem_Tour";
            tabItem_Tour.Text = "Quản lý tour";
            // 
            // tabCtrlPanel_Tour
            // 
            tabCtrlPanel_Tour.Controls.Add(tbl_Tour);
            tabCtrlPanel_Tour.Controls.Add(btn_exitTour);
            tabCtrlPanel_Tour.Controls.Add(btn_delTour);
            tabCtrlPanel_Tour.Controls.Add(btn_editTour);
            tabCtrlPanel_Tour.Controls.Add(btn_addTour);
            tabCtrlPanel_Tour.Controls.Add(txt_timTour);
            tabCtrlPanel_Tour.Controls.Add(labelX1);
            tabCtrlPanel_Tour.Controls.Add(buttonX2);
            tabCtrlPanel_Tour.Dock = System.Windows.Forms.DockStyle.Fill;
            tabCtrlPanel_Tour.Location = new System.Drawing.Point(0, 26);
            tabCtrlPanel_Tour.Name = "tabCtrlPanel_Tour";
            tabCtrlPanel_Tour.Padding = new System.Windows.Forms.Padding(1);
            tabCtrlPanel_Tour.Size = new System.Drawing.Size(1269, 512);
            tabCtrlPanel_Tour.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(142)))), ((int)(((byte)(179)))), ((int)(((byte)(231)))));
            tabCtrlPanel_Tour.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(237)))), ((int)(((byte)(254)))));
            tabCtrlPanel_Tour.Style.Border = eBorderType.SingleLine;
            tabCtrlPanel_Tour.Style.BorderColor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(97)))), ((int)(((byte)(156)))));
            tabCtrlPanel_Tour.Style.BorderSide = ((eBorderSide)(((eBorderSide.Left | eBorderSide.Right)
            | eBorderSide.Bottom)));
            tabCtrlPanel_Tour.Style.GradientAngle = 90;
            tabCtrlPanel_Tour.TabIndex = 1;
            tabCtrlPanel_Tour.TabItem = tabItem_Tour;
        }

        private void tabCtrlQL_TabItemClose(object sender, TabStripActionEventArgs e)
        {
            tabCtrlQL.Tabs.Remove(tabCtrlQL.SelectedTab);
        }

        private void btnItem_KS_Click(object sender, EventArgs e)
        {
            TabControlPanel tabCtrlPanel_KS;
            tabCtrlPanel_KS = new TabControlPanel();
            tabCtrlPanel_KS.SuspendLayout();
            tabCtrlQL.Controls.Add(tabCtrlPanel_KS);


            TabItem tabItem_KS = new TabItem();
            tabCtrlQL.Tabs.Add(tabItem_KS);
            // 
            // tabItem_KS
            // 
            tabItem_KS.AttachedControl = tabCtrlPanel_KS;
            tabItem_KS.Name = "tabItem_KS";
            tabItem_KS.Text = "Quản lý khách sạn";
            // 
            // tabCtrlPanel_KS
            // 
            tabCtrlPanel_KS.Controls.Add(tbl_KhachSan);
            tabCtrlPanel_KS.Controls.Add(btn_exitKS);
            tabCtrlPanel_KS.Controls.Add(btn_delKS);
            tabCtrlPanel_KS.Controls.Add(btn_editKS);
            tabCtrlPanel_KS.Controls.Add(btn_addKS);
            tabCtrlPanel_KS.Controls.Add(txt_timKS);
            tabCtrlPanel_KS.Controls.Add(labelX2);
            tabCtrlPanel_KS.Dock = System.Windows.Forms.DockStyle.Fill;
            tabCtrlPanel_KS.Location = new System.Drawing.Point(0, 26);
            tabCtrlPanel_KS.Name = "tabCtrlPanel_KS";
            tabCtrlPanel_KS.Padding = new System.Windows.Forms.Padding(1);
            tabCtrlPanel_KS.Size = new System.Drawing.Size(1269, 512);
            tabCtrlPanel_KS.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(142)))), ((int)(((byte)(179)))), ((int)(((byte)(231)))));
            tabCtrlPanel_KS.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(237)))), ((int)(((byte)(254)))));
            tabCtrlPanel_KS.Style.Border = eBorderType.SingleLine;
            tabCtrlPanel_KS.Style.BorderColor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(97)))), ((int)(((byte)(156)))));
            tabCtrlPanel_KS.Style.BorderSide = ((eBorderSide)(((eBorderSide.Left | eBorderSide.Right)
            | eBorderSide.Bottom)));
            tabCtrlPanel_KS.Style.GradientAngle = 90;
            tabCtrlPanel_KS.TabIndex = 2;
            tabCtrlPanel_KS.TabItem = tabItem_KS;
        }

        private void btnItem_NH_Click(object sender, EventArgs e)
        {
            TabItem tabItem_NH = new TabItem();
            tabCtrlQL.Tabs.Add(tabItem_NH);

            TabControlPanel tabCtrlPanel_NH;
            tabCtrlPanel_NH = new TabControlPanel();
            tabCtrlPanel_NH.SuspendLayout();
            tabCtrlQL.Controls.Add(tabCtrlPanel_NH);
            // 
            // tabItem_NH
            // 
            tabItem_NH.AttachedControl = tabCtrlPanel_NH;
            tabItem_NH.Name = "tabItem_NH";
            tabItem_NH.Text = "Quản lý nhà hàng";


            // 
            // tabCtrlPanel_NH
            // 
            tabCtrlPanel_NH.Controls.Add(tbl_NhaHang);
            tabCtrlPanel_NH.Controls.Add(btn_exitNH);
            tabCtrlPanel_NH.Controls.Add(btn_delNH);
            tabCtrlPanel_NH.Controls.Add(btn_editNH);
            tabCtrlPanel_NH.Controls.Add(btn_addNH);
            tabCtrlPanel_NH.Controls.Add(txt_NH);
            tabCtrlPanel_NH.Controls.Add(labelX3);
            tabCtrlPanel_NH.Dock = System.Windows.Forms.DockStyle.Fill;
            tabCtrlPanel_NH.Location = new System.Drawing.Point(0, 26);
            tabCtrlPanel_NH.Name = "tabCtrlPanel_NH";
            tabCtrlPanel_NH.Padding = new System.Windows.Forms.Padding(1);
            tabCtrlPanel_NH.Size = new System.Drawing.Size(1269, 512);
            tabCtrlPanel_NH.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(142)))), ((int)(((byte)(179)))), ((int)(((byte)(231)))));
            tabCtrlPanel_NH.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(237)))), ((int)(((byte)(254)))));
            tabCtrlPanel_NH.Style.Border = eBorderType.SingleLine;
            tabCtrlPanel_NH.Style.BorderColor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(97)))), ((int)(((byte)(156)))));
            tabCtrlPanel_NH.Style.BorderSide = ((eBorderSide)(((eBorderSide.Left | eBorderSide.Right)
            | eBorderSide.Bottom)));
            tabCtrlPanel_NH.Style.GradientAngle = 90;
            tabCtrlPanel_NH.TabIndex = 3;
            tabCtrlPanel_NH.TabItem = tabItem_NH;
        }

        private void btnItem_VT_Click(object sender, EventArgs e)
        {
            TabControlPanel tabCtrlPanel_VT;
            tabCtrlPanel_VT = new TabControlPanel();
            tabCtrlPanel_VT.SuspendLayout();
            tabCtrlQL.Controls.Add(tabCtrlPanel_VT);
            TabItem tabItem_VT = new TabItem();
            tabCtrlQL.Tabs.Add(tabItem_VT);
            // 
            // tabItem_VT
            // 
            tabItem_VT.AttachedControl = tabCtrlPanel_VT;
            tabItem_VT.Name = "tabItem_VT";
            tabItem_VT.Text = "Quản lý vận tải";
            // 
            // tabCtrlPanel_VT
            // 
            tabCtrlPanel_VT.Controls.Add(tbl_VanTai);
            tabCtrlPanel_VT.Controls.Add(btn_exitVT);
            tabCtrlPanel_VT.Controls.Add(btn_delVT);
            tabCtrlPanel_VT.Controls.Add(btn_EditVT);
            tabCtrlPanel_VT.Controls.Add(btn_addVT);
            tabCtrlPanel_VT.Name = "tabCtrlPanel_VT";
            tabCtrlPanel_VT.Padding = new System.Windows.Forms.Padding(1);
            tabCtrlPanel_VT.Size = new System.Drawing.Size(1269, 512);
            tabCtrlPanel_VT.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(142)))), ((int)(((byte)(179)))), ((int)(((byte)(231)))));
            tabCtrlPanel_VT.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(237)))), ((int)(((byte)(254)))));
            tabCtrlPanel_VT.Style.Border = eBorderType.SingleLine;
            tabCtrlPanel_VT.Style.BorderColor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(97)))), ((int)(((byte)(156)))));
            tabCtrlPanel_VT.Style.BorderSide = ((eBorderSide)(((eBorderSide.Left | eBorderSide.Right)
            | eBorderSide.Bottom)));
            tabCtrlPanel_VT.Style.GradientAngle = 90;
            tabCtrlPanel_VT.TabIndex = 4;
            tabCtrlPanel_VT.TabItem = tabItem_VT;
        }


        private void btnItem_NV_Click(object sender, EventArgs e)
        {
            TabControlPanel tabCtrlPanel_NV;
            tabCtrlPanel_NV = new TabControlPanel();
            tabCtrlPanel_NV.SuspendLayout();
            tabCtrlQL.Controls.Add(tabCtrlPanel_NV);
            TabItem tabItem_NV = new TabItem();
            tabCtrlQL.Tabs.Add(this.tabItem_NV);
            // 
            // tabItem_NV
            // 
            tabItem_NV.AttachedControl = tabCtrlPanel_NV;
            tabItem_NV.Name = "tabItem_NV";
            tabItem_NV.Text = "Quản lý nhân viên";
            // 
            // tabCtrlPanel_NV
            // 
            tabCtrlPanel_NV.Controls.Add(tbl_NhanVien);
            tabCtrlPanel_NV.Controls.Add(btn_exitNV);
            tabCtrlPanel_NV.Controls.Add(btn_delNV);
            tabCtrlPanel_NV.Controls.Add(btn_EditNV);
            tabCtrlPanel_NV.Controls.Add(btn_addNV);
            tabCtrlPanel_NV.Controls.Add(txt_NV);
            tabCtrlPanel_NV.Controls.Add(labelX6);
            tabCtrlPanel_NV.Dock = System.Windows.Forms.DockStyle.Fill;
            tabCtrlPanel_NV.Location = new System.Drawing.Point(0, 26);
            tabCtrlPanel_NV.Name = "tabCtrlPanel_NV";
            tabCtrlPanel_NV.Padding = new System.Windows.Forms.Padding(1);
            tabCtrlPanel_NV.Size = new System.Drawing.Size(1269, 512);
            tabCtrlPanel_NV.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(142)))), ((int)(((byte)(179)))), ((int)(((byte)(231)))));
            tabCtrlPanel_NV.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(237)))), ((int)(((byte)(254)))));
            tabCtrlPanel_NV.Style.Border = eBorderType.SingleLine;
            tabCtrlPanel_NV.Style.BorderColor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(97)))), ((int)(((byte)(156)))));
            tabCtrlPanel_NV.Style.BorderSide = ((eBorderSide)(((eBorderSide.Left | eBorderSide.Right)
            | eBorderSide.Bottom)));
            tabCtrlPanel_NV.Style.GradientAngle = 90;
            tabCtrlPanel_NV.TabIndex = 6;
            tabCtrlPanel_NV.TabItem = tabItem_NV;
        }
        //====================================================================================================================================================================

        private void QL_Load(object sender, EventArgs e)
        {
            DiaDanh_thucthe dd_tt = new DiaDanh_thucthe();
            DiaDanh_dieukhien dd_dk = new DiaDanh_dieukhien();
            Tour_dieukhien tour_dk = new Tour_dieukhien();
            KhachSan_dieukhien ks_dk = new KhachSan_dieukhien();
            NhaHang_dieukhien nh_dk = new NhaHang_dieukhien();
            VanTai_dieukhien vt_dk = new VanTai_dieukhien();
            NhanVien_dieukhien nv_dk = new NhanVien_dieukhien();
            tbl_Tour.DataSource = tour_dk.danhSachTour();
            tbl_KhachSan.DataSource = ks_dk.danhSachKhachSan();
            tbl_NhaHang.DataSource = nh_dk.danhSachNhaHang();
            tbl_VanTai.DataSource = vt_dk.danhSachVanTai();
            tbl_NhanVien.DataSource = nv_dk.danhSachNhanVien();
            tbl_diaDanh.DataSource = dd_dk.danhSachDiaDanh();
        }
        
        
        public static int hang;

        //int dong;


        // ///////////////////////////////////////////////////////////////////////////Khach san


        KhachSan_dieukhien ks_dk = new KhachSan_dieukhien();
        KhachSan_thucthe kss_tt = new KhachSan_thucthe();
        private void btn_addKS_Click(object sender, EventArgs e)
        {
            QL_KhachSan ks = new QL_KhachSan();
            ks.ShowDialog();
            QL_Load(sender, e);
        }

        private void btn_editKS_Click(object sender, EventArgs e)
        {
            QL_KhachSan_sua frm_ks_sua = new QL_KhachSan_sua();
            frm_ks_sua.loadKhachSan(kss_tt);
            frm_ks_sua.ShowDialog();
            QL_Load(sender, e);
        }

        private void btn_delKS_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có muốn xóa ?", "Khach san", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                KhachSan_thucthe ks = new KhachSan_thucthe();
                KhachSan_dieukhien dk = new KhachSan_dieukhien();
                ks.MaKhachSan = int.Parse(tbl_KhachSan.CurrentRow.Cells[0].Value.ToString());
                int kq = dk.xoa_KhachSan(ks);
                if (kq > 0)
                {
                    MessageBox.Show("Xóa thành công");
                }
                QL_Load(sender, e);
            }
        }

        private void btn_exitKS_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void buttonX10_Click(object sender, EventArgs e)
        {
            KhachSan_thucthe ks = new KhachSan_thucthe();
            KhachSan_dieukhien dk = new KhachSan_dieukhien();
            ks.TenKhachSan = txt_timKS.Text.Trim();
            tbl_KhachSan.DataSource = dk.timKhachSan(ks);
        }


        private void tbl_KhachSan_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int dong = e.RowIndex;
            if (dong >= 0 & dong < (tbl_KhachSan.RowCount - 1))
            {
                kss_tt.MaKhachSan = int.Parse(tbl_KhachSan.Rows[dong].Cells[0].Value.ToString());
                kss_tt.TenKhachSan = tbl_KhachSan.Rows[dong].Cells[1].Value.ToString();
                kss_tt.DiaChi = tbl_KhachSan.Rows[dong].Cells[2].Value.ToString();
                kss_tt.Email = tbl_KhachSan.Rows[dong].Cells[3].Value.ToString();
                kss_tt.Sdt = tbl_KhachSan.Rows[dong].Cells[4].Value.ToString();
                kss_tt.MoTa = tbl_KhachSan.Rows[dong].Cells[5].Value.ToString();
            }
        }

        //  //////////////////////////////////////////////////////////////////////// Nha hang
        private void btn_addNH_Click(object sender, EventArgs e)
        {
            QL_NhaHang nh = new QL_NhaHang();
            nh.ShowDialog();
            QL_Load(sender, e);
        }

        NhaHang_thucthe nhs_tt = new NhaHang_thucthe();
        private void btn_editNH_Click(object sender, EventArgs e)
        {
            QL_NhaHang_sua frm_nh_sua = new QL_NhaHang_sua();
            frm_nh_sua.ShowDialog();
            frm_nh_sua.loadNhaHang(nhs_tt);
            QL_Load(sender, e);
        }

        private void btn_delNH_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có muốn xóa ?", "Nhà hàng", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                NhaHang_dieukhien dk = new NhaHang_dieukhien();
                NhaHang_thucthe nh = new NhaHang_thucthe();
                nh.MaNhaHang = int.Parse(tbl_NhaHang.CurrentRow.Cells[0].Value.ToString().Trim());
                dk.xoaNhaHang(nh);
                if (dk.xoaNhaHang(nh) > 0)
                {
                    MessageBox.Show("Xóa thành công");
                    QL_Load(this, e);
                }
            }
        }
        private void buttonX11_Click(object sender, EventArgs e)
        {
            NhaHang_dieukhien nh_dk = new NhaHang_dieukhien(); 
            NhaHang_thucthe nh_tt = new NhaHang_thucthe();
            nh_tt.TenNhaHang = txt_NH.Text.Trim();
            tbl_NhaHang.DataSource =  nh_dk.timNhaHang(nh_tt);
        }
        private void tbl_NhaHang_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int dong = e.RowIndex;
            if (dong >= 0 & dong < (tbl_NhaHang.RowCount - 1))
            {
                nhs_tt.MaNhaHang = int.Parse(tbl_NhaHang.Rows[dong].Cells[0].Value.ToString());
                nhs_tt.TenNhaHang = tbl_NhaHang.Rows[dong].Cells[1].Value.ToString();
                nhs_tt.DiaChi = tbl_NhaHang.Rows[dong].Cells[2].Value.ToString();
                nhs_tt.Email = tbl_NhaHang.Rows[dong].Cells[3].Value.ToString();
                nhs_tt.Sdt = tbl_NhaHang.Rows[dong].Cells[4].Value.ToString();
                nhs_tt.MoTa = tbl_NhaHang.Rows[dong].Cells[5].Value.ToString();
            }
        }
        // /////////////////////////////////////////////////////////////////////Van tai

        private void btn_addVT_Click(object sender, EventArgs e)
        {
            QL_VanTai vt = new QL_VanTai();
            vt.ShowDialog();
            QL_Load(this, e);
        }

        private void btn_EditVT_Click(object sender, EventArgs e)
        {
            QL_VanTai_sua frm_vt_sua = new QL_VanTai_sua();
            frm_vt_sua.loadVanTai(vts_tt);
            frm_vt_sua.ShowDialog();
            QL_Load(this, e);
        }

        private void btn_delVT_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có muốn xóa ?", "Vận tải", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                VanTai_dieukhien vt_dk = new VanTai_dieukhien(); VanTai_thucthe vt_tt = new VanTai_thucthe();
                vt_tt.MaVanTai = int.Parse(tbl_VanTai.CurrentRow.Cells[0].Value.ToString());
                vt_dk.xoaVanTai(vt_tt);
                int kq = vt_dk.xoaVanTai(vt_tt);
                if (kq > 0)
                {
                    MessageBox.Show("Xóa thành công");
                    QL_Load(this, e);
                }
            }
        }

        private void btn_exitVT_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btn_exitNH_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        private void buttonX12_Click(object sender, EventArgs e)
        {
            VanTai_dieukhien vt_dk = new VanTai_dieukhien(); VanTai_thucthe vt_tt = new VanTai_thucthe();
            vt_tt.TenVanTai = txt_VT.Text.Trim();
            tbl_VanTai.DataSource =  vt_dk.timVanTai(vt_tt);
        }
        VanTai_thucthe vts_tt = new VanTai_thucthe();
        private void tbl_VanTai_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int dong = e.RowIndex;
            if (dong > 0 & dong < (tbl_VanTai.RowCount - 1))
            vts_tt.MaVanTai = int.Parse(tbl_VanTai.Rows[e.RowIndex].Cells[0].Value.ToString());
            vts_tt.TenVanTai = tbl_VanTai.Rows[e.RowIndex].Cells[1].Value.ToString();
            vts_tt.LoaiHinh = tbl_VanTai.Rows[e.RowIndex].Cells[2].Value.ToString();
            vts_tt.MoTa = tbl_VanTai.Rows[e.RowIndex].Cells[3].Value.ToString();
            vts_tt.Sdt = tbl_VanTai.Rows[e.RowIndex].Cells[4].Value.ToString();
            vts_tt.Email = tbl_VanTai.Rows[e.RowIndex].Cells[5].Value.ToString();

        }
        //    //////////////////////////////////////////////////////////////////////////////////Nhan vien


        private void tbl_NhanVien_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int dong = e.RowIndex;
            if (dong >= 0 & dong < (tbl_NhanVien.RowCount - 1))
            {
                nvs_tt.MaNhanVien = int.Parse(tbl_NhanVien.Rows[dong].Cells[0].Value.ToString());
                nvs_tt.TenNhanVien = tbl_NhanVien.Rows[dong].Cells[1].Value.ToString();
                nvs_tt.NgaySinh = tbl_NhanVien.Rows[dong].Cells[2].Value.ToString();
                nvs_tt.Sdt = tbl_NhanVien.Rows[dong].Cells[4].Value.ToString();
                nvs_tt.Email = tbl_NhanVien.Rows[dong].Cells[5].Value.ToString();
                nvs_tt.DiaChi = tbl_NhanVien.Rows[dong].Cells[6].Value.ToString();
                nvs_tt.ChucVu = tbl_NhanVien.Rows[dong].Cells[7].Value.ToString();
                nvs_tt.MatKhau = tbl_NhanVien.Rows[dong].Cells[8].Value.ToString();
                nvs_tt.Quyen = tbl_NhanVien.Rows[dong].Cells[9].Value.ToString();
            }
        }
        private void btn_addNV_Click(object sender, EventArgs e)
        {
            QL_NhanVien nv = new QL_NhanVien();
            nv.ShowDialog();
            QL_Load(sender, e);
        }

        NhanVien_thucthe nvs_tt = new NhanVien_thucthe();
        private void btn_EditNV_Click(object sender, EventArgs e)
        {
            QL_NhanVien_sua nv = new QL_NhanVien_sua();
            nv.loadNhanVien(nvs_tt);
            nv.ShowDialog();
            QL_Load(sender, e);
        }

        private void btn_delNV_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có muốn xóa ?", "Nhân viên", MessageBoxButtons.OKCancel)==DialogResult.OK)
            {
                NhanVien_dieukhien nv_dk = new NhanVien_dieukhien();
                NhanVien_thucthe nv_tt = new NhanVien_thucthe();
                nv_tt.MaNhanVien =int.Parse(tbl_NhanVien.CurrentRow.Cells[0].Value.ToString());
                nv_dk.xoaNhanVien(nv_tt);
                if (nv_dk.xoaNhanVien(nv_tt) > 0)
                {
                    MessageBox.Show("Xóa thành công");
                    QL_Load(sender, e);
                }
            }
        }

        private void btn_exitNV_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        private void buttonX13_Click(object sender, EventArgs e)
        {
            NhanVien_dieukhien nv_dk = new NhanVien_dieukhien();
            NhanVien_thucthe nv_tt = new NhanVien_thucthe();
            nv_tt.TenNhanVien = txt_NV.Text.Trim();
            tbl_NhanVien.DataSource = nv_dk.timNhanVien(nv_tt);
        }

        /////////////////////////////////////////////////////////////////////////////////////////////////////////////Tour



        DiaDanh_thucthe ddss_tt = new DiaDanh_thucthe();
        //NhanVien_thucthe nv_tt = new NhanVien_thucthe();
        //ChiTiet_Tour_DiaDanh tour_dd = new ChiTiet_Tour_DiaDanh();
        //ChiTiet_Tour_KhachSan tour_ks = new ChiTiet_Tour_KhachSan();
        KhachSan_thucthe ksss_tt = new KhachSan_thucthe();
        //ChiTiet_Tour_NhaHang tour_nh = new ChiTiet_Tour_NhaHang();
        NhaHang_thucthe nhss_tt = new NhaHang_thucthe();
        //ChiTiet_Tour_VanTai tour_vt = new ChiTiet_Tour_VanTai();
        VanTai_thucthe vtss_tt = new VanTai_thucthe();
        //Tour_dieukhien tour_dk = new Tour_dieukhien();
        Tour_thucthe tours_tt = new Tour_thucthe();
        private void btn_timTour_Click(object sender, EventArgs e)
        {
            Tour_dieukhien dk = new Tour_dieukhien(); 
            Tour_thucthe tt = new Tour_thucthe();
            tt.MaTour = txt_timTour.Text.Trim();
            tbl_Tour.DataSource = dk.timTour(tt);
        }

        private void btn_addTour_Click(object sender, EventArgs e)
        {
            QL_Tour_them frm_tour_them = new QL_Tour_them();
            frm_tour_them.ShowDialog();
            QL_Load(sender, e);
        }
        private void btn_editTour_Click(object sender, EventArgs e)
        {
            QL_Tour_sua frm_tour_sua = new QL_Tour_sua();
            frm_tour_sua.ShowDialog();
            frm_tour_sua.loadTour(tours_tt, dds_tt, kss_tt, nhs_tt, vts_tt);
            QL_Load(sender, e);

        }
        private void btn_delTour_Click(object sender, EventArgs e)
        {
            Tour_dieukhien tour_dk = new Tour_dieukhien(); Tour_thucthe tour_tt = new Tour_thucthe();
            MessageBox.Show("Bạn có muốn xóa ?", "Tour", MessageBoxButtons.OKCancel);
            int hang = int.Parse(tbl_Tour.CurrentRow.Index.ToString());
            tour_tt.MaTour = tbl_Tour.Rows[hang].Cells[0].Value.ToString().Trim();
            int kq = tour_dk.xoaTour(tour_tt);
            if (kq > 0)
            {
                MessageBox.Show("Xóa thành công.");
            }
            QL_Load(sender, e);
        }


        private void tbl_Tour_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int dong = e.RowIndex;
            if (dong >= 0 & dong < (tbl_Tour.RowCount - 1))
            {
                tours_tt.MaTour = tbl_Tour.Rows[dong].Cells[0].Value.ToString();
                tours_tt.TenTour = tbl_Tour.Rows[dong].Cells[1].Value.ToString();
                tours_tt.NoiKhoiHanh = tbl_Tour.Rows[dong].Cells[2].Value.ToString();
                tours_tt.MoTa = tbl_Tour.Rows[dong].Cells[3].Value.ToString();
                tours_tt.LoaiHinh = tbl_Tour.Rows[dong].Cells[4].Value.ToString();
                tours_tt.GiaCa = long.Parse(tbl_Tour.Rows[dong].Cells[5].Value.ToString());
                ddss_tt.MaDiaDanh = int.Parse(tbl_Tour.Rows[dong].Cells[6].Value.ToString());
                dds_tt.TenDiaDanh = tbl_Tour.Rows[dong].Cells[7].Value.ToString();
                nhss_tt.MaNhaHang = int.Parse(tbl_Tour.Rows[dong].Cells[8].Value.ToString());
                nhss_tt.TenNhaHang = tbl_Tour.Rows[dong].Cells[9].Value.ToString();
                kss_tt.MaKhachSan = int.Parse(tbl_Tour.Rows[dong].Cells[10].Value.ToString());
                kss_tt.TenKhachSan = tbl_Tour.Rows[dong].Cells[11].Value.ToString();
                vtss_tt.MaVanTai = int.Parse(tbl_Tour.Rows[dong].Cells[12].Value.ToString());
                vts_tt.TenVanTai = tbl_Tour.Rows[dong].Cells[13].Value.ToString();
            }
        }
        private void btn_exitTour_Click(object sender, EventArgs e)
        {
            this.Close();
        }


        /////////////////////////////////////////////////////////////////Dia Danh/////////////////////////////////////////////////////////////////////
        
        
        
        private void buttonX14_Click(object sender, EventArgs e)
        {
            DiaDanh_dieukhien dd_dk = new DiaDanh_dieukhien(); 
            DiaDanh_thucthe dd_tt = new DiaDanh_thucthe();
            dd_tt.TenDiaDanh = txt_timDiaDanh.Text.Trim();
            tbl_diaDanh.DataSource = dd_dk.timDiaDanh(dd_tt);
        }

        private void buttonX1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void buttonX5_Click(object sender, EventArgs e)
        {
            QL_DiaDanh_Them frm_dd_them = new QL_DiaDanh_Them();
            frm_dd_them.ShowDialog();
            QL_Load(this, e);
        }
        DiaDanh_dieukhien dd_dk = new DiaDanh_dieukhien();
        DiaDanh_thucthe dds_tt = new DiaDanh_thucthe();
        private void buttonX4_Click(object sender, EventArgs e)
        {
            QL_DiaDanh_sua frm_dd_sua = new QL_DiaDanh_sua();
            frm_dd_sua.ShowDialog();
            frm_dd_sua.loadDuLieu(dds_tt);
            QL_Load(sender, e);
        }
        // lay du lieu tu bang
        private void tbl_diaDanh_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int dong = e.RowIndex;
            if (dong >= 0 & dong < (tbl_diaDanh.RowCount - 1))
            {
                dds_tt.MaDiaDanh = int.Parse(tbl_diaDanh.Rows[dong].Cells[0].Value.ToString());
                dds_tt.TenDiaDanh = tbl_diaDanh.Rows[dong].Cells[1].Value.ToString();
                dds_tt.MoTa = tbl_diaDanh.Rows[dong].Cells[2].Value.ToString();
                dds_tt.DiaChi = tbl_diaDanh.Rows[dong].Cells[3].Value.ToString();
            }
        }

        private void buttonX3_Click(object sender, EventArgs e)
        {

            if (MessageBox.Show("Bạn có muốn xóa địa danh ?", "Xóa", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK )
            {
                DiaDanh_thucthe dd_tt = new DiaDanh_thucthe();
                dd_tt.MaDiaDanh = int.Parse(tbl_diaDanh.CurrentRow.Cells[0].Value.ToString());
                int kq = dd_dk.xoaDiaDanh(dd_tt);
                if (kq > 0)
                {
                    MessageBox.Show("Xóa thành công", "Xóa");
                }
                QL_Load(sender, e);
            }
        }

        private void ribbonControl1_Click(object sender, EventArgs e)
        {

        }

        private void tbl_Tour_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
    }
}
